//
//  StewardTableHeaderView.m
//  VTravel
//
//  Created by lanouhn on 16/8/2.
//  Copyright © 2016年 xiaoYu. All rights reserved.
//

#import "StewardTableHeaderView.h"

@implementation StewardTableHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setup];
    }
    return self;
}

- (void)setup{
    NSArray *array = @[@"案例", @"评分", @"全部"];
    for (int i = 0; i < 3; i ++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(kScreenWidth / 3 * i, 0, kScreenWidth / 3, self.frame.size.height);
        [button setTitle:array[i] forState:(UIControlStateNormal)];
        [button setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        button.tag = 200 + i;
        button.backgroundColor = [UIColor whiteColor];
        [button addTarget:self action:@selector(handleButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
        if (i != 2) {
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(kScreenWidth / 3 - 2, 5, 2, self.frame.size.height - 10)];
            view.backgroundColor = [UIColor orangeColor];
            [button addSubview:view];
        }
        self.userInteractionEnabled = YES;
        [self addSubview:button];
    }
}
#pragma mark - button的点击事件
- (void)handleButtonAction:(UIButton *)sender{
    if (self.StewardBlock) {
        self.StewardBlock(sender.tag);
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
